using Asxsyd92Core.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using WebOS.Dal;
namespace WebOS.Modle
{

    [TableName("RoleApp")]
    [Description("RoleApp")]
    public partial class RoleApp
    {
        public System.Guid ID { get; set; }
        public System.Guid ParentID { get; set; }
        public System.Guid RoleID { get; set; }
        public Nullable<System.Guid> AppID { get; set; }
        public string Title { get; set; }
        public string Params { get; set; }
        public int Sort { get; set; }
        public string Ico { get; set; }
        public int Type { get; set; }

        public string icon { get; set; }

        public string tag { get; set; }

        public int tagtype { get; set; }
        public int openType { get; set; }
        public int maxOpen { get; set; }
        public string Color { get; set; }
        public string extend { get; set; }
        [DbField(false)]
        public long Count { get; set; }

        [DbField(false)]
        public Guid id { get { return this.ID; } }

        [DbField(false)]
        public int identifier { get; set; }
        [DbField(false)]
        public string name { get { return this.Title; } }
        [DbField(false)]
        public string title { get { return this.Title; } }
        [DbField(false)]
        public List<RoleApp> children
        {
            get
            {
                string sql = "select * from RoleApp RA,( select MenuID, ur.identifier from UsersRole ur, Role r where  ur.identifier = r.identifier and r.identifier = " + this.identifier + ") as tab  where RA.ParentID = '" + this.ID + "' and tab.MenuID = RA.ID and ParentID !='00000000-0000-0000-0000-000000000000' order by Sort";
                return RoleAppDal.Instance.GetList(sql, null).ToList();
            }
        }

    }

    [TableName("RoleApp")]
    [Description("RoleApp")]
    public partial class xRoleApp
    {
        public System.Guid ID { get; set; }
        public System.Guid ParentID { get; set; }
        public System.Guid RoleID { get; set; }
        public Nullable<System.Guid> AppID { get; set; }
        public string Title { get; set; }
        public string Params { get; set; }
        public int Sort { get; set; }
        public string Ico { get; set; }
        public int Type { get; set; }

        public string icon { get; set; }

        public string tag { get; set; }

        public int tagtype { get; set; }
        public int openType { get; set; }
        public int maxOpen { get; set; }
        public string Color { get; set; }
        public string extend { get; set; }
        [DbField(false)]
        public long Count { get; set; }

        [DbField(false)]
        public Guid id { get { return this.ID; } }

        [DbField(false)]
        public string title { get { return this.Title; } }
        [DbField(false)]
        public string name { get { return this.Title; } }
        [DbField(false)]
        public int identifier { get; set; }
        [DbField(false)]
        public List<xRoleApp> children
        {
            get
            {

                string sql = "select * from RoleApp where ParentID='" + this.ID + "' order by Sort";
                return xRoleAppDal.Instance.GetList(sql, null).ToList();


            }

        }
    }
}